<?php

	/**
	 * Workspace@ Engine application comment!
	 * 
	 * LICENSE
	 * This application is licensed under New BSD license.
	 * Please read complete LICENSE.txt inside of root folder for more details.
	 * 
	 * We wish you happy building :) 
	 * 
	 * @category   Application
	 * @package    Bootstrap
	 * @author     Nevio Vesic <nevio@workspaceat.com>
	 * @copyright  2008-2009 Workspace@ group in association with Design strategist
	 */

	/**
	 * Enter description here...
	 *
	 */
	class Engine_Application_Configuration_Frontend
	{
		
		/**
		 * Base path to application configuration directory
		 */
		const CONF_BASE_PATH     = "";
		
		const SETTINGS_FILE      = "system.ini";
		
		/**
		 * System configuration file object
		 *
		 * @var Object[Zend_Config_Ini]
		 */
		public static $system    = null;
		
		/**
		 * Initialize system configuration
		 *
		 * @param  string $appname
		 * @return Object[Zend_Config_Ini]
		 */
		function __construct( $appname )
		{
			$system_file = self::CONF_BASE_PATH . strtolower( $appname ) . DIRECTORY_SEPARATOR . self::SETTINGS_FILE;
			if (! fopen( $system_file, "r", true  ) )
			{
				throw new Engine_Exception( "Frontend configuration file cannot be resolved. Please reinstall application!" );
			}
			
			
			if( self::$system )
			{
				self::$system = null;
			}
			
			self::$system = new Zend_Config_Ini( $system_file, 'Frontend' );
			
			return self::$system;
		}
		
		/**
		 * Get system configuration instance of Zend_Config_Ini
		 *
		 * @return Object[Zend_Config_Ini]
		 */
		public function getSystemInstance()
		{
			return self::$system;
		}
		
	}